package utils;

/**
 * Used to send integer value by reference, replaces the immutable Integer class
 */
public class MutableInteger { // TODO should be deleted

	// member
	
	private int val; // wrapped integer value
	
	// public methods
	
	/**
	 * Constructor- creates a new mutable integer object
	 * @param val- integer value to be wrapped 
	 */
	public MutableInteger(int val) {
		
		// set member as given value
		this.val = val;
	}
	
	/**
	 * Returns wrapped integer value
	 * @return wrapped value
	 */
	public int get() { return val; }
	
	/**
	 * Sets wrapped value as given value
	 * @param newVal- new value to wrap 
	 */
	public void set(int newVal) { this.val = newVal; }
	
	/**
	 * Increments wrapped value and returns it after incrementing
	 * @return value after incrementing
	 */
	public int inc() {return ++val; }
	
	/**
	 * Returns printing format of wrapped value 
	 */
	public String toString() {
		return String.valueOf(val);
	}
}